﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EmotionRecognitionGui
{ 
    public class GuiManager : IDisposable
    {
        public FormStartPosition startPosition;

        public int currentuserID;
        public enum Folders { MMI, Externals, Facs };
        public static int auCount = 38;
        /// <summary>
        /// GuiManager- Will hold All Gui Windows
        /// </summary>
        protected GuiManager()
        {

        }
        protected static GuiManager instance = null; 
        public UserLogin userLoginGui;
        public DataBaseImages dataBaseImagesGui;
        public InitialEndowment initialEndowmentGui;
        public MainMenuExpert mainMenuExpertGui;
        public MainMenuReviewer mainMenuReviewerGui;
        public RefinePrefences refinePrefencesGui;
        public Registeration registerationGui;
        public TakeImage takeImageGui;
        public UserFeedBack userFeedBackGui;
        public ImageAnalysis ImageAnalysisGui;
        public UpdateLastImages updateLastImages;
        public Statistics statistics;
        public About about;
        public void Init()
        {
            //
            ImageAnalysisGui = new ImageAnalysis();
            userLoginGui = new UserLogin();
            dataBaseImagesGui = new DataBaseImages();
            initialEndowmentGui = new InitialEndowment();
            mainMenuExpertGui = new MainMenuExpert();
            mainMenuReviewerGui = new MainMenuReviewer();
            refinePrefencesGui = new RefinePrefences();
            registerationGui = new Registeration();
            takeImageGui = new TakeImage();
            userFeedBackGui = new UserFeedBack();
            updateLastImages = new UpdateLastImages();
            statistics = new Statistics();
            about = new About();
        }

        public static GuiManager Instance //singleton
        {
            get
            {
                if (instance == null)
                {
                    instance = new GuiManager();
                }
                return instance;
            }
        }
        //
        public void StartProgram()
        {
            try
            {
                Application.EnableVisualStyles();
                // Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(userLoginGui);

            }
            catch (Exception e)
            {
                MessageBox.Show("Error: " + e.ToString());
            }
        }

        public void SwitchForms(Form formHide,Form formShow) //change the window position
        {
            formShow.Left = formHide.Left;
            formShow.Top = formHide.Top;
            formHide.Hide();
            formShow.Show();
        }
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                // dispose managed resources
                userLoginGui.Close();
                dataBaseImagesGui.Close();
                initialEndowmentGui.Close();
                mainMenuExpertGui.Close();
                mainMenuReviewerGui.Close();
                refinePrefencesGui.Close();
                registerationGui.Close();
                takeImageGui.Close();
                userFeedBackGui.Close();
                ImageAnalysisGui.Close();
                updateLastImages.Close();
                //statistics.Close();
                about.Close();
            }
            // free native resources
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }
    }
}
